#pragma
#include<iostream>

using namespace std;

class Date
{
public:
	int getmonthday(int year, int month)
	{
		static int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)))
		{
			return 29;
		}
		return arr[month];
	}

	void print();

	bool CheckDate();

	Date(int year = 1, int month = 1, int day = 1)
	{
		if (CheckDate())
		{
			_year = year;
			_month = month;
			_day = day;
		}
		else
		{
			_year = 1;
			_month = 1;
			_day = 1;
		}
	}

	Date& operator+=(int day);
	Date& operator-=(int day);
	Date operator-(int day);
	Date operator+(int day);
	Date& operator++();
	Date operator++(int);
	Date& operator--();
	Date operator--(int);

	bool operator==(const Date& d) const;
	bool operator!=(const Date& d) const;
	bool operator<(const Date& d) const;
	bool operator<=(const Date& d) const;
	bool operator>(const Date& d) const;
	bool operator>=(const Date& d) const;

	int operator-(const Date& d) const;

	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);

private:
	int _year;
	int _month;
	int _day;
};

ostream& operator<<(ostream& out, const Date& d);
istream& operator>>(istream& in, Date& d);